/**
 * Vue自定义指令，相当于一个中间件
 */
const hasPermission = {
  install (Vue, options) {
    Vue.directive('hasPermission', {
      bind (el, binding, vnode) {
        let permissionList = vnode.context.$route.meta.permTypes;
        // console.log('permissionList:', permissionList)
        // console.log('binding.value:', binding.value)
        if (permissionList && permissionList.length && !permissionList.includes(binding.value)) {
          el.parentNode.removeChild(el);
        }
      }
    });
  }
};

export default hasPermission;
